package com.miso.shop.controller;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.miso.shop.model.DdongVO0010;
import com.miso.shop.service.DdongService0010;
import com.miso.shop.service.DdongService0020;



/**
 * @author 
 * @Description : 怨좉컼�곷떞硫붿씤�붾㈃-�듯솕�덉빟�깅줉
 * @Class : CnsController0090
 * <pre>
 * </pre>
 * @version : 1.0
 */
@Controller
@RequestMapping("/daum/ddongs/")
public class DaumCafeController0020 {
    private static Logger logger = LoggerFactory.getLogger(DaumCafeController0010.class);
	private final static String PROGRAM_ID = "daum.ddongs";
	private final static String programUrl = PROGRAM_ID.replaceAll("\\.", "/");
	/** Wfm0010 Service */
	@Resource(name = "ddongService0020")
    private DdongService0020 ddongService0020;


	
	/** 
	 * @Method		: �몄텧 �붾㈃
	 * @author		: jh.choi
	 * @Locaton		: com.hyundaicard.privia.counsel.cns.CnsController0090
	 * @Description	: �듯솕�덉빟�깅줉 �붾㈃���몄텧�쒕떎.
	 * @param		: model
	 * @return		: String
	 * @throws Exception 
	 */
	@RequestMapping("/noticeList")  //어노테이션 설정 /main으로 url요청이 들어오면 이 컨트롤러로 매핑하겠단 뜻.
	public String ddong0020 (
			Model model) {

		return programUrl + "/ddong0020";
	}
	
	/** 
	 * @Method		: setCustRrvInfo
	 * @author		: jh.choi
	 * @Locaton		: com.hyundaicard.privia.counsel.cns.CnsController0090
	 * @Description	: �듯솕�덉빟 ��옣
	 * @param		: CnsVO0090, Model
	 * @return		: String
	 * @throws Exception 
	 */
	@RequestMapping("ddong0020.setNoticeMsg") 
	public @ResponseBody Object setNoticeMsg(
			@ModelAttribute("vo") DdongVO0010 vo,
			Model model) {


	    ddongService0020.insert ("miso.ddong.mysql.DDONG0020_setNoticeMsg_INS", vo);

		return null;
	}
	
	/** 
	 * @Method		: setCustRrvInfo
	 * @author		: jh.choi
	 * @Locaton		: com.hyundaicard.privia.counsel.cns.CnsController0090
	 * @Description	: �듯솕�덉빟 ��옣
	 * @param		: CnsVO0090, Model
	 * @return		: String
	 * @throws Exception 
	 */
	@RequestMapping("ddong0020.modNoticeMsg") 
	public @ResponseBody int modNoticeMsg(
			@ModelAttribute("vo") DdongVO0010 vo,
			Model model) {

        logger.debug("#getSeq########## : "+vo.getSeq());
		//CnsVO0110 vo = new CnsVO0110();

		return ddongService0020.update ("miso.ddong.mysql.DDONG0020_setNoticeMsg_UPD", vo);
	}
	
	/** 
	 * @Method		: setCustRrvInfo
	 * @author		: jh.choi
	 * @Locaton		: com.hyundaicard.privia.counsel.cns.CnsController0090
	 * @Description	: �듯솕�덉빟 ��옣
	 * @param		: CnsVO0090, Model
	 * @return		: String
	 * @throws Exception 
	 */
	@RequestMapping("ddong0020.delNoticeMsg") 
	public @ResponseBody int delNoticeMsg(
			@ModelAttribute("vo") DdongVO0010 vo,
			Model model) {

        logger.debug("#getSeq########## : "+vo.getSeq());
		//CnsVO0110 vo = new CnsVO0110();
		

		
		//System.out.println("====================================================3131"+result.get(0).getShop_name());


		return ddongService0020.delete ("miso.ddong.mysql.DDONG0020_delNoticeMsg_DEL", vo);
	}	
	
	/*
	// http://hmkcode.com/spring-mvc-jquery-file-upload-multiple-dragdrop-progress/ 참고
	@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
	@ResponseBody
	public List<FileMeta> upload(
	    @RequestParam(value = "files[]", required = false) MultipartFile[] files) throws IllegalStateException, IOException {
	 
	  List<FileMeta> fileMetas = new ArrayList<FileMeta>();
	  for (MultipartFile file : files) {
	    File uploadFile = new File("/", file.getOriginalFilename());
	    file.transferTo(uploadFile);
	    FileMeta fileMeta = new FileMeta(uploadFile.getAbsolutePath(), file.getSize(), "");
	    fileMetas.add(fileMeta);
	  }
	 
	  return fileMetas;
	}
	*/
}